package com.JadeForum.forum.controller;

import com.JadeForum.forum.common.AppResult;
import com.JadeForum.forum.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: yyx
 * Date: 2024-04-18
 * Time: 21:06
 */
@Api(tags = "测试类的相关接口")
@RestController
@RequestMapping("/test")
public class TestController {

    @ApiOperation(value = "测试接⼝1，异常的处理")
    @GetMapping("/exception")
    public AppResult testE() throws Exception {
        throw new Exception("这是小玉测试的exception");
    }
    @ApiOperation(value = "测试接⼝2，自定义的异常的处理")
    @GetMapping("/Appexception")
    public AppResult testAppE() {
        throw new ApplicationException("这是小玉测试的自定义Appexception");
    }

    @ApiOperation(value = "测试接口3，传入参数返回你好")
    @RequestMapping("/hello")
    public AppResult helloByParam(@ApiParam("姓名") @RequestParam("name") String name){
        return AppResult.success("你好"+name);
    }
}
